export const sourceType = (window.env === 'imDesktop' ? 8001 : 1001);

// 获取环境变量(pre. daily.)
export function getENV() {
    if (process.env.NODE_ENV === 'development') {
        return `${process.env.VUE_APP_DEV_ENV}.`
    } else if (process.env.NODE_ENV === "daily" || process.env.NODE_ENV === "pre") {
        return `${process.env.NODE_ENV}.`
    }
    return ''
}

// 获取环境变量的code(1-日常,2-预发,3-线上)
export function getENVCode() {
    if (process.env.NODE_ENV === 'development') {
        return `${process.env.VUE_APP_CODE_ENV}.`
    } else if (process.env.NODE_ENV === "daily") {
        return 1
    } else if (process.env.NODE_ENV === "pre") {
        return 2
    }
    return 3
}

export function getENVType() {
    const envCode = getENVCode()
    return {
        1: 'daily',
        2: 'pre',
        3: 'prod'
    }[envCode]
}

// 获取接口地址thor.pre.idcvdian.com
export function setAPI(apiType) {
    if (apiType === 'thor') {
        if (process.env.NODE_ENV === 'development') {
            return '/thor'
        }
        return `http://thor.${getENV()}weidian.com`

    }
    if (apiType === 'tinyput') {
        return `http://tinyput.vdian.net`
    }
    if (process.env.NODE_ENV === 'development') {
        if (apiType === 'attendApi') {
            return '/attendApi'
        } else {
            return '/api'
        }
    }
    if (apiType === 'attendApi') {
        return `//attend-management.${getENV()}vdian.net`
    } else {
        return `//fly.viicb.com/lwscApi`
    }
}